home *** CD-ROM | disk | FTP | other *** search
/ PC Media 7 / PC MEDIA CD07.iso / share / prog / cm / cmtdeque.cc < prev    next >
Encoding:
Text File  |  1994-09-06  |  1.7 KB  |  71 lines

  1. // CmTDeque.cc
  2. // -----------------------------------------------------------------
  3. // Compendium - C++ Container Class Library
  4. // Copyright (C) 1992-1994, Glenn M. Poorman, All rights reserved
  5. // -----------------------------------------------------------------
  6. // Deque (double ended queue) template implementation.
  7. // -----------------------------------------------------------------
  8.  
  9.  
  10. // "CmTDeque" is the deque copy constructor.
  11. //
  12. template <class T> CmTDeque<T>::CmTDeque(const CmTDeque<T>& S)
  13.                               : CmTLinkedList<T>(S)
  14. {}
  15.  
  16.  
  17. // "=" operator copies the contents of the input queue into this queue.
  18. //
  19. template <class T> CmTDeque<T>& CmTDeque<T>::operator=(const CmTDeque<T>& S)
  20. {
  21.   return (CmTDeque<T>&) CmTLinkedList<T>::operator=(S);
  22. }
  23.  
  24.  
  25. // "pushLeft" pushes the specified item into queue left.
  26. //
  27. template <class T> Bool CmTDeque<T>::pushLeft(const T& obj)
  28. {
  29.   return prepend(obj);
  30. }
  31.  
  32.  
  33. // "pushRight" pushes the specified item into queue right.
  34. //
  35. template <class T> Bool CmTDeque<T>::pushRight(const T& obj)
  36. {
  37.   return append(obj);
  38. }
  39.  
  40.  
  41. // "popLeft" removes the left item from the queue and returns a copy.
  42. //
  43. template <class T> T CmTDeque<T>::popLeft()
  44. {
  45.   return removeFirst();
  46. }
  47.  
  48.  
  49. // "popRight" removes the right item from the queue and returns a copy.
  50. //
  51. template <class T> T CmTDeque<T>::popRight()
  52. {
  53.   return removeLast();
  54. }
  55.  
  56.  
  57. // "peekLeft" returns a copy of the left queue item.
  58. //
  59. template <class T> const T& CmTDeque<T>::peekLeft() const
  60. {
  61.   return first();
  62. }
  63.  
  64.  
  65. // "peekRight" returns a copy of the right queue item.
  66. //
  67. template <class T> const T& CmTDeque<T>::peekRight() const
  68. {
  69.   return last();
  70. }
  71.